<html lang="zh_CN">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CoruiLab</title>
    <link rel="stylesheet" href="style.css">
  </head>
  <body>
    <div id="app">
      <image src="./images/zilogo.svg" class="zituLogo" />
      <div class="loading">
        <p style="font-size: .6rem;margin: 3% auto 0;" class="qidong">服务正在启动中，请稍侯</p>
        <div class="sport">
          <span class="l1"></span>
          <span class="l2"></span>
          <span class="l3"></span>
          <span class="l4"></span>
        </div>
      </div>
      <p style="font-size: .6rem;margin: 5% auto 0;color: red;display: none;" class="fail">服务启动失败，请联系管理员</p>
    </div>
    <script>
      let timeoutMin = 0;
      let req = setInterval(function(){
        conn()
      }, 1000);

      function conn(){
        timeoutMin++
        fetch(window.CallBridge?.serveUrl + '/api/login', {
          method: 'GET',
          headers: {
            'Content-Type': 'application/json'
          }
        })
        .then(data => {
          if(data?.status < 500){
            window.CallBridge?.invokeMethod?.('conn', true)
            clearInterval(req)
          }
          
          if(timeoutMin >= 120) {
            clearInterval(req);
            alert("服务启动失败，请联系管理员")
            window.CallBridge?.invokeMethod?.('quit')
          }

        })
        .catch(error => {
          
        });
      }
    </script>
  </body>
</html>